#include<iostream>
using namespace std;
int main() {
	int x,y,n,z,max_z=-1,min_z=999999;
	string id,max_id,min_id;
	cin>>n;
	for(int i=0; i<n; i++) {
		cin>>id>>x>>y;
		z=x*x+y*y;
		if(z>max_z) {
			max_z=z;
			max_id=id;
		}
		if(z<min_z) {
			min_z=z;
			min_id=id;
		}
	}
	cout<<min_id<<" "<<max_id;
	return 0;
}
